﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LifeTree.DomainModel.Entities;
using System.Data.Entity;

namespace LifeTree.EntityFrameworkProvider.Tests.Repositories
{
    public class InMemoryLifeTreeContext : ILifeTreeContext
    {
        private readonly InMemoryDbSet<Task> tasks;
        private readonly InMemoryDbSet<Workbook> workbooks;

        public InMemoryLifeTreeContext()
        {
            this.tasks = new InMemoryDbSet<Task>();
            this.workbooks = new InMemoryDbSet<Workbook>();

        }

        public IDbSet<Task> Tasks
        {
            get { return this.tasks; }
        }

        public IDbSet<Workbook> Workbooks
        {
            get { return this.workbooks; }
        }

        public IDbSet<T> GetSetByType<T>() where T : class
        {
            if (typeof(T) == typeof(Task))
                return this.tasks as IDbSet<T>;

            if (typeof(T) == typeof(Workbook))
                return this.workbooks as IDbSet<T>;

            throw new InvalidOperationException();
        }

        public int SaveChanges()
        {
            return 0;
        }
    }
}
